<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Paymentmanagement
 *
 * @author Sorasak Siangsanan
 */
class PaymentmanagementController extends Controller {

    public function actionIndex() {
        $model = new Payment('search');
        $model->unsetAttributes();  // clear any default values
        if (isset($_GET['Payment'])) {
            $model->attributes = $_GET['Payment'];
        }
        $this->render('index', array('model' => $model));
    }
    
    public function actionView() {

        $id = $_GET["id"];
        if (isset($id)) {
            $payment = Payment::model()->findByPk($id);
            if (!isset($payment)) {
                $this->redirect(array('paymentmanagement/index'));
            }
        } else {
            $this->redirect(array('paymentmanagement/index'));
        }

        $this->render('view', array('payment' => $payment));
    }

    public function actionVieworder() {

        $id = $_GET["id"];
        if (isset($id)) {
            $order = Order::model()->findByPk($id);
            if (!isset($order)) {
                $this->redirect(array('paymentmanagement/index'));
            }
        } else {
            $this->redirect(array('paymentmanagement/index'));
        }

        $this->render('vieworder', array('order' => $order));
    }

    public function actionConfirm() {

        $id = $_GET["id"];
        if (isset($id)) {
            $order = Order::model()->findByPk($id);
            if (isset($order)) {
                $order->status_id = 3;
                $order->update_date = date("Y-m-d H:i:s");
                $order->update();
            }
        }

        $this->redirect(array('paymentmanagement/index'));
    }

}
